package com.next.aap.server.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SmsUtil {
	
	private static Logger logger = LoggerFactory.getLogger(SmsUtil.class);
	public static final String USER_NAME = "nextinfotch";
	public static final String PASSWORD = "1720250318";
	public static final String SENDER_NAME = "way2ghar";
	
	public static void main(String[] args){
		sednAdSms("Ravi", "8901550600", "Test Message");
	}
	private static void sednAdSms(String name,String phoneNumber,String message){
		try{
				
				String urlString = "http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?username="+SmsUtil.USER_NAME+"&password="+SmsUtil.PASSWORD+"&sendername="+SmsUtil.SENDER_NAME+"&mobileno=91"+phoneNumber+"&message="+message; 
				logger.warn("urlString = "+ urlString);
	            URL url = new URL(urlString);
	            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
	            String line;

	            while ((line = reader.readLine()) != null) {
	            	logger.warn("Output=" + line);
	            }
	            reader.close();

	        } catch (Exception e) {
	        	logger.warn(e.getMessage(),e);
	        }
			
		}
}
